<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="libs/html5.js"></script>
    <script type="text/javascript" src="libs/respond.min.js"></script>
    <script type="text/javascript" src="libs/PIE_IE678.js"></script>
    <![endif]-->
    <link href="libs/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="libs/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
    <link href="libs/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>登录 - 接口自动化测试平台</title>
    </head>
<body>
<input type="hidden" id="TenantId" name="TenantId" value="" />
<div class="header"></div>
<div class="loginWraper">
    <div id="loginform" class="loginBox">
        <form class="form form-horizontal" action="index.html" method="post">
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="username"  type="text" placeholder="账户" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
                <div class="formControls col-xs-8">
                    <input id="password"  type="password" placeholder="密码" class="input-text size-L">
                </div>
            </div>
            <!--<div class="row cl">-->
                <!--<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe613;</i></label>-->
                    <!--<div class="formControls col-xs-8">             -->
	                    <!--<input id="verifyCode"  type="text" placeholder="验证码" class="input-text size-L" style="width:280px;">                 -->
	                    <!--<img src="img/code.png" style="width:80px;height:40px;cursor:pointer;"/>    -->
                	<!--</div>-->
            <!--</div>-->
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <label for="online">
                        <input type="checkbox" name="online" id="online" checked="checked">使我保持登录状态</label>
                </div>
            </div>        
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <input id="loginBtn" type="button" class="btn btn-success radius size-L" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
                    <input name="" type="reset" class="btn btn-default radius size-L" value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
                    <p id="loginTip" style="color: red;"></p>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="footer">Copyright By MasterYi Devops@2017-2019 <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1275927783'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s23.cnzz.com/z_stat.php%3Fid%3D1275927783%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));</script></div>
<script type="text/javascript" src="libs/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript" src="libs/h-ui/js/H-ui.js"></script>
<script>
    $(document).ready(function(){   	
    	 // $("#verifyCode").siblings('img').click(function(){
    		//  let that = this;
    		//  $.get('user-createVerifyCode', function(data){
        	// 	 if (data.returnCode == 0) {
        	// 		 $(that).attr('src', data.path);
        	// 	 }
        	//  });
    	 // });
    	 //
    	 // $("#verifyCode").siblings('img').click();
    	 
    	 $("#loginBtn").click(userLogin);
    	 //监听键盘回车事件
    	 $(document).keyup(function (event) {
    		 var keycode = event.which;
    		 if(keycode==13){
    			 $("#loginBtn").click(); 
    		 }
    		 
    	 });
        //判断当前是否有用户登录
        $.post("user-judgeLogin",function(data){
            if(data.returnCode == 0){
                //跳转首页
            	window.location.href="index.html";
            }else{
            	//没有登录的时候检查cookie
            	var username = getCookie("username");
            	var loginIdentification = getCookie("loginIdentification");
            	if(username != null && loginIdentification != null){
            		postLogin(username, null, null,loginIdentification);
            	}
            }
        });
    });
    // function userLogin(){
    //     var username = $("#username").val();
    //     var password = $("#password").val();
    //     var verifyCode = $("#verifyCode").val();$
    //     if(username != "" && username != null
    //     		&& password != "" && password != null
    //     		&& verifyCode != "" && verifyCode != null){
    //     	postLogin(username,password, verifyCode, null);
    //     }else{
    //         tipMsg.text("请填写完整再提交登录");
    //     }
    // }

    function userLogin(){
        var username = $("#username").val();
        var password = $("#password").val();

        if(username != "" && username != null
            && password != "" && password != null
            ){
            postLogin(username,password, null);
        }else{
            tipMsg.text("请填写完整再提交登录");
        }
    }
    
    // function postLogin(username, password, verifyCode,loginIdentification){
    // 	var tipMsg = $("#loginTip");
    // 	$.post("user-toLogin",{
    //         username:username,
    //         password:password,
    //         verifyCode:verifyCode,
    //         loginIdentification:loginIdentification
    //     },function(data){
    //         if(data.returnCode==0){
    //         	if($("#online").is(':checked') == true && loginIdentification == null){
    //         		setCookie("username", username, 7);
    //         		setCookie("loginIdentification", data.data.loginIdentification, 7);
    //         	}
    //             location.href="index.html";
    //         }else {
    //         	 tipMsg.text(data.msg);
    //         }
    //     });
    // }

    function postLogin(username, password,loginIdentification){
        var tipMsg = $("#loginTip");
        $.post("user-toLogin",{
            username:username,
            password:password,

            loginIdentification:loginIdentification
        },function(data){
            if(data.returnCode==0){
                if($("#online").is(':checked') == true && loginIdentification == null){
                    setCookie("username", username, 7);
                    setCookie("loginIdentification", data.data.loginIdentification, 7);
                }
                location.href="index.html";
            }else {
                tipMsg.text(data.msg);
            }
        });
    }
</script>
</body>
</html>